package com.butterfly.demo.action;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.butterfly.demo.model.Student;
import com.butterfly.demo.service.StudentService;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class StudentAction extends ActionSupport implements ModelDriven<Student>{
	private Student student;
	private StudentService studentService;
	
	//添加方法
	public String add() throws Exception {
		studentService.add(student);
		return SUCCESS;
	}
	//登录方法
	public String login(){
		student = studentService.login(student);
		if(student!=null){
			return "loginSuccess";
		}
		return "loginFail";
	}
	public StudentService getStudentService() {
		return studentService;
	}
	@Resource
	public void setStudentService(StudentService studentService) {
		this.studentService = studentService;
	}

	public Student getStudent() {
		return student;
	}
	@Resource
	public void setStudent(Student student) {
		this.student = student;
	}

	public Student getModel() {
		return student;
	}
	
}
